package cn.stylefeng.guns.modular.business.controller;

import cn.stylefeng.guns.modular.business.dto.DeviceConfigQuery;
import cn.stylefeng.guns.modular.business.dto.DeviceConfigUpdateOrAddDto;
import cn.stylefeng.guns.modular.business.service.DeviceConfigService;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/deviceconfig")
@Api(tags = "设备配置接口", description = "设备配置接口相关接口")
public class DeviceConfigController  {

    @Autowired
    private DeviceConfigService deviceConfigService;

    @GetMapping("/findPage")
    @ApiOperation("分页查询设备配置接口")
    public ResponseData page(@Validated DeviceConfigQuery deviceConfigQuery) {
        return new SuccessResponseData(this.deviceConfigService.findPage(deviceConfigQuery));
    }

    @GetMapping("/detail")
    @ApiOperation("查询设备配置详情")
    public ResponseData detail(@RequestParam("id") Integer id) {
        return new SuccessResponseData(this.deviceConfigService.detail(id));
    }

    @PostMapping("/editOrAdd")
    @ApiOperation("编辑或新增设备配置")
    public ResponseData editOrAdd(@RequestBody @Validated DeviceConfigUpdateOrAddDto deviceConfigUpdateDto) {
        this.deviceConfigService.editOrAdd(deviceConfigUpdateDto);
        return new SuccessResponseData();
    }


}
